﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TfsBacklogMgr.Main.Mocks;

namespace TfsBacklogMgr.Main
{
    public class MockWorkItemType
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

    public class MockWorkItem
    {
        public MockWorkItem(string TypeName, User AssignedTo, int points, int hours, int remain, WorkItem parent)
        {
            Type = new MockWorkItemType();
            Type.Name = TypeName;

            Random rnd = new Random();
            // StackRank = rnd.Next() % 100;
            Description = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
            Description = Description.Substring(0, 9 + (rnd.Next() % 90));
            State = "Active";
            Reason = "Assigned";

            Fields = new MockWorkItemFields();
            Fields[Microsoft.TeamFoundation.WorkItemTracking.Client.CoreField.AssignedTo].Value = AssignedTo.Login;
            Fields["Hours"].Value = hours;
            Fields["Remain"].Value = remain;
            Fields["Points"].Value = points;

            // parent
            WorkItemLinks = new MockWorkItemLinks();
            if (parent != null)
            {
                var mockParent = new MockWorkItemLink("Parent");
                mockParent.TargetId = parent.Id;
                WorkItemLinks.Add( mockParent );
            }
        }
        public int Id { get; set; }
        public MockWorkItemType Type { get; set; }
        public string IterationPath { get; set; }
        public string AreaPath { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public string State { get; set; }
        public string Reason { get; set; }
        public MockWorkItemFields Fields { get; set; }
        public MockWorkItemLinks WorkItemLinks { get; set; }
    }
}
